{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 前馈神经网络\n",
    "\n",
    "### 1、 加载数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 加载 MNIST 数据\n",
    "import mnist_loader\n",
    "training_data, validation_data, test_data = mnist_loader.load_data_wrapper()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 训练模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0: 9005 / 10000\n",
      "Epoch 1: 9235 / 10000\n",
      "Epoch 2: 9294 / 10000\n",
      "Epoch 3: 9301 / 10000\n",
      "Epoch 4: 9388 / 10000\n",
      "Epoch 5: 9387 / 10000\n",
      "Epoch 6: 9417 / 10000\n",
      "Epoch 7: 9428 / 10000\n",
      "Epoch 8: 9471 / 10000\n",
      "Epoch 9: 9459 / 10000\n",
      "Epoch 10: 9481 / 10000\n",
      "Epoch 11: 9436 / 10000\n",
      "Epoch 12: 9493 / 10000\n",
      "Epoch 13: 9468 / 10000\n",
      "Epoch 14: 9467 / 10000\n",
      "Epoch 15: 9468 / 10000\n",
      "Epoch 16: 9480 / 10000\n",
      "Epoch 17: 9488 / 10000\n",
      "Epoch 18: 9498 / 10000\n",
      "Epoch 19: 9494 / 10000\n",
      "Epoch 20: 9470 / 10000\n",
      "Epoch 21: 9494 / 10000\n",
      "Epoch 22: 9472 / 10000\n",
      "Epoch 23: 9461 / 10000\n",
      "Epoch 24: 9487 / 10000\n",
      "Epoch 25: 9453 / 10000\n",
      "Epoch 26: 9485 / 10000\n",
      "Epoch 27: 9490 / 10000\n",
      "Epoch 28: 9497 / 10000\n",
      "Epoch 29: 9494 / 10000\n"
     ]
    }
   ],
   "source": [
    "import network\n",
    "net = network.Network([784, 30, 10])\n",
    "net.SGD(training_data, 30, 10, 3.0, test_data=test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0: 8402 / 10000\n",
      "Epoch 1: 8532 / 10000\n",
      "Epoch 2: 8560 / 10000\n",
      "Epoch 3: 8589 / 10000\n",
      "Epoch 4: 9429 / 10000\n",
      "Epoch 5: 9513 / 10000\n",
      "Epoch 6: 9530 / 10000\n",
      "Epoch 7: 9561 / 10000\n",
      "Epoch 8: 9546 / 10000\n",
      "Epoch 9: 9567 / 10000\n",
      "Epoch 10: 9596 / 10000\n",
      "Epoch 11: 9596 / 10000\n",
      "Epoch 12: 9588 / 10000\n",
      "Epoch 13: 9598 / 10000\n",
      "Epoch 14: 9577 / 10000\n",
      "Epoch 15: 9607 / 10000\n",
      "Epoch 16: 9602 / 10000\n",
      "Epoch 17: 9619 / 10000\n",
      "Epoch 18: 9609 / 10000\n",
      "Epoch 19: 9622 / 10000\n",
      "Epoch 20: 9619 / 10000\n",
      "Epoch 21: 9639 / 10000\n",
      "Epoch 22: 9638 / 10000\n",
      "Epoch 23: 9627 / 10000\n",
      "Epoch 24: 9637 / 10000\n",
      "Epoch 25: 9629 / 10000\n",
      "Epoch 26: 9633 / 10000\n",
      "Epoch 27: 9650 / 10000\n",
      "Epoch 28: 9637 / 10000\n",
      "Epoch 29: 9649 / 10000\n"
     ]
    }
   ],
   "source": [
    "net2 = network.Network([784, 100, 10])\n",
    "net2.SGD(training_data, 30, 10, 3.0, test_data=test_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0: 5628 / 10000\n",
      "Epoch 1: 7471 / 10000\n",
      "Epoch 2: 8283 / 10000\n",
      "Epoch 3: 8321 / 10000\n",
      "Epoch 4: 8308 / 10000\n",
      "Epoch 5: 8358 / 10000\n",
      "Epoch 6: 8333 / 10000\n",
      "Epoch 7: 8366 / 10000\n",
      "Epoch 8: 8368 / 10000\n",
      "Epoch 9: 8372 / 10000\n",
      "Epoch 10: 8368 / 10000\n",
      "Epoch 11: 8366 / 10000\n",
      "Epoch 12: 8385 / 10000\n",
      "Epoch 13: 8377 / 10000\n",
      "Epoch 14: 8378 / 10000\n",
      "Epoch 15: 8367 / 10000\n",
      "Epoch 16: 8385 / 10000\n",
      "Epoch 17: 8360 / 10000\n",
      "Epoch 18: 8375 / 10000\n",
      "Epoch 19: 8382 / 10000\n",
      "Epoch 20: 8383 / 10000\n",
      "Epoch 21: 8385 / 10000\n",
      "Epoch 22: 8385 / 10000\n",
      "Epoch 23: 8411 / 10000\n",
      "Epoch 24: 8404 / 10000\n",
      "Epoch 25: 8389 / 10000\n",
      "Epoch 26: 8394 / 10000\n",
      "Epoch 27: 8384 / 10000\n",
      "Epoch 28: 8389 / 10000\n",
      "Epoch 29: 8386 / 10000\n"
     ]
    }
   ],
   "source": [
    "net3 = network.Network([784, 10])\n",
    "net3.SGD(training_data, 30, 10, 3.0, test_data=test_data)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
